package cn.tedu.fcms.customer.associatedaccount.controller;

import cn.tedu.fcms.base.response.JsonResult;
import cn.tedu.fcms.customer.associatedaccount.pojo.dto.AssociatedAccountParam;
import cn.tedu.fcms.customer.associatedaccount.pojo.dto.AssociatedAccountQuery;
import cn.tedu.fcms.customer.associatedaccount.pojo.vo.AssociatedAccountVO;
import cn.tedu.fcms.customer.associatedaccount.service.AssociatedAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/customer/associatedAccount/")
public class AssociatedAccountController {

    @Autowired
    AssociatedAccountService associatedAccountService;

    @GetMapping("query")
    public JsonResult select(AssociatedAccountQuery query) {
        List<AssociatedAccountVO> vo = associatedAccountService.query(query);
        return JsonResult.ok(vo);
    }

    @PostMapping("add")
    public JsonResult add(AssociatedAccountParam param) {
        AssociatedAccountVO vo = associatedAccountService.add(param);
        return JsonResult.ok(vo);
    }

    @PostMapping("update")
    public JsonResult update(AssociatedAccountParam param) {
        AssociatedAccountVO vo = associatedAccountService.update(param);
        return JsonResult.ok(vo);
    }

    @PostMapping("remove")
    public JsonResult remove(Long applicationId) {
        AssociatedAccountVO vo = associatedAccountService.remove(applicationId);
        return JsonResult.ok(vo);
    }

    @PostMapping("submitApproval")
    public JsonResult submitApproval(Long applicationId) {
        AssociatedAccountVO vo = associatedAccountService.submitApproval(applicationId);
        return JsonResult.ok(vo);
    }

    @PostMapping("approve")
    public JsonResult approve(AssociatedAccountParam param) {
        AssociatedAccountVO vo = associatedAccountService.approve(param);
        return JsonResult.ok(vo);
    }

    @PostMapping("delete")
    public JsonResult delete(Long applicationId) {
        AssociatedAccountVO vo = associatedAccountService.delete(applicationId);
        return JsonResult.ok(vo);
    }

}
